<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
        <main>
            <a href="http://houdunren.com">后盾人</a>
            <a href="http://hdcms.com">hdcms</a>
            <a href="http://yahoo.com">雅虎</a>
            <h4>http://www.hdcms.com</h4>
        </main>
</body>
<script>
     //要求只给hdcms houdunren加上www.、
    let main = document.querySelector("body main")
    let reg = /(<a.*href=['"])(http:\/\/)(www\.)?(houdunren|hdcms)/ig
    main.innerHTML = main.innerHTML.replace(reg,(v,...args)=>{
        args[1] = "https://"
        args[2] = args[2] || "www.";
        console.log(args);
        return args.splice(0,4).join("")
    })
</script>
</html>